package IO;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileRead {
    public static void main(String[] args) {
        FileReader reader=null;
        try {//创建读内存流
            reader =new FileReader("D:\\BanGong\\TestFile\\temm.txt");
            //读内容
            char[] chars =new char[4];
            int readCount = 0;//定义一个变量，用来计数（读到的字符数量）
            //将读的内容打印出来
            while(true){
                try {
                    if (((readCount =reader.read(chars))!=-1)) {
                        System.out.print(new String(chars,0,readCount));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
